<script setup>
import { GetRawChecktAPI } from '@/api/order/sale/order'
const { proxy } = getCurrentInstance()
// 封装 方法 字典查询
const { sales_order_detail_status } = proxy.useDict('sales_order_detail_status')

// 封装 方法 字典查询
const props = defineProps({
  data: {
    type: Array,
    default: []
  },
  id: {
    type: String,
    default: ''
  }
})

/**
 * 状态参数
 */
const state = reactive({
  loading: false
})

/**
 * 表格数据
 */
const tableData = ref(props.data)

/**
 * 表单数据
 */
const ruleForm = reactive({ list: [] })
ruleForm.list = props.data

/**
 * 列表枚举
 */
const column = ref([
  {
    label: '物料编码',
    prop: 'materialCode',
    width: '120'
  },
  {
    label: '产品名称',
    prop: 'materialName',
    width: '120'
  },
  {
    label: '单据状态',
    prop: 'orderDetailStatus',
    width: '120'
  },
  {
    label: '规格型号',
    prop: 'specType'
  },
  {
    label: '交货日期',
    prop: 'deliveryDate'
  },
  {
    label: '订单数量',
    prop: 'planWeight'
  },
  {
    label: '计算数量',
    prop: 'computeNum',
    width: '180'
  },
  {
    label: '成品库存数',
    prop: 'stockNum',
    width: '120'
  },
  {
    label: '是否运算',
    prop: 'operationFlag',
    width: '180'
  }
])

/**
 * 删除
 */
const remove = record => {
  const index = ruleForm.list.findIndex(item => item.id == record.id)
  ruleForm.list.splice(index, 1)
}

const submit = async () => {
  return ruleForm
}

defineExpose({ submit })
</script>
<template>
  <div class="app-container">
    <p-table :loading="state.loading" :data="ruleForm.list" :column="column">
      <template #columnCell="{ column, record }">
        <!-- 单据状态 -->
        <p-dictTag
          v-if="column.prop == 'orderDetailStatus'"
          :options="sales_order_detail_status"
          :value="record.orderDetailStatus"
        />
        <!-- 计算数量 -->
        <div v-if="column.prop == 'computeNum'">
          <el-input type="number" clearable v-model="record.computeNum" />
        </div>
        <!-- 锁定库存 -->
        <div v-if="column.prop == 'lockedNum'">
          <el-input clearable v-model="record.lockedNum" />
        </div>
      </template>
    </p-table>
  </div>
</template>

<style scoped lang="scss">
.rk ::v-deep .el-form-item {
  width: 100% !important;
}
</style>
